package StratelegoGame;
import java.awt.Color;
import java.util.Set;

/**
 * Class for creating a piece holding hoard.
 * @author Jace Ferguson
 * @filename GameBoard2DPieceHoard.java
 *
 */
public class GameBoard2DPieceHoard extends GameBoard2D implements GameBoardPieceHoard
{
	/**
	 * Create a hoard to hold a specified number of pieces.
	 * @param rows int	number of rows in the hoard
	 * @param columns	int	number of pieces in the hoard
	 */
	public GameBoard2DPieceHoard(Integer rows, Integer columns)
	{
		super(rows, columns);
		super.setBackgroundColor(Color.YELLOW);
	}
	
	/**
	 * Recalculate the size of the spaces.
	 */
	public void recalculateHoard()
	{
		super.recalculateBoard();
	}
	
	/**
	 * Set the hoard parameters
	 * @param row	int	number of rows
	 * @param columns	int number of columns
	 */
	public void setDimensions(Integer rows, Integer columns)
	{
		super.setBoardDimensions(rows, columns);
	}
	
	/**
	 * Add a piece to the hoard.
	 */
	public void addPiece(GameBoardPiece piece)
	{
		//Get the keys for all the spaces in the hoard
		Set<Integer> keys = this.spaces.keySet();
		
		for(Integer key : keys) //Go and find an empty space
		{
			GameBoardSpace space = this.spaces.get(key);
			if(space.isEmpty()) //If the space is empty put the piece on it and break
			{
				space.addPieceToSpace(piece);
				break;
			}
		}
	}
	
	/**
	 * Empty the piece hoard.
	 */
	public void clearHoard()
	{
		super.clearBoard();
	}
}


